﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace QuanLyNhanVien.DataAccessLayer
{
    class MADataAccessHelper
    {
        protected static string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=QLNV.mdb";
        public static DataTable ExecQuery(string s)
        {
            OleDbDataAdapter adapter = new OleDbDataAdapter(s, connectionString);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            return dt;
        }
        public static void ExecNonQuery(string s)
        {
            OpenConnection();
            OleDbCommand cmd = new OleDbCommand(s, connection);
            cmd.ExecuteNonQuery();
            CloseConnection();
        }
        protected static OleDbConnection connection = null;
        protected static void OpenConnection()
        {
            connection = new OleDbConnection(connectionString);
            connection.Open();
        }
        protected static void CloseConnection()
        {
            if (connection != null)
                connection.Close();
        }
    }
}
